package com.zhuss.product.train;

import com.zhuss.bean.bo.product.train.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.DzcxException;

/**
 * @description: 线路策略操作的Service
 * @author: zhushanshuo
 * @create: Mon Jan 04 09:51:07 CST 2021
 **/
@Component("lineStrategyOperateService")
public class LineStrategyOperateService implements OperateService<Void, Object> {

	@Autowired
	@Qualifier("lineStrategyCreate")
	private Processor<Object, CreateLineStrategyBo> lineStrategyCreate;

	@Autowired
	@Qualifier("lineStrategyUpdate")
	private Processor<Object, UpdateLineStrategyBo> lineStrategyUpdate;

	@Autowired
	@Qualifier("lineStrategyDelete")
	private Processor<Object, DeleteLineStrategyBo> lineStrategyDelete;

	@Autowired
	@Qualifier("strategySiteBind")
	private Processor<Object, BindStrategySiteBo> strategySiteBind;

	@Autowired
	@Qualifier("strategySell")
	private Processor<Object, BindStrategySiteBo> strategySell;

	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws DzcxException {

		CreateLineStrategyBo bo = (CreateLineStrategyBo) param;

		lineStrategyCreate.process(bo);

		return null;
	}

	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws DzcxException {

		UpdateLineStrategyBo bo = (UpdateLineStrategyBo) param;

		lineStrategyUpdate.process(bo);

    	return null;
    }

	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws DzcxException {

		DeleteLineStrategyBo bo = (DeleteLineStrategyBo) param;

		lineStrategyDelete.process(bo);

		return null;
	}


	@Transactional(rollbackFor = Exception.class)
	public Void editSite(BindStrategySiteBo bo) throws DzcxException {
		strategySiteBind.process(bo);
		return null;
	}

	@Transactional(rollbackFor = Exception.class)
	public Void sell(BindStrategySiteBo bo) throws DzcxException {
		strategySell.process(bo);
		return null;
	}

}

